package com.example.demo.action.common;/**
 * Created by kete on 2018-11-27.
 */

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

/**
 * 作者：kete
 * 创建时间：2018-11-27 17:08
 * 功能描述：
 * 版本：
 */
public class HeartBeatDecode extends ByteToMessageDecoder {

    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {
        long id = byteBuf.readLong() ;
        byte[] bytes = new byte[byteBuf.readableBytes()] ;

        byteBuf.readBytes(bytes) ;
        String content = new String(bytes) ;

        list.add(new CustomProtocol(id,content));
    }
}
